//计算冬奥会开幕时间
package com.shidaimanong.demo.date;

import java.time.LocalDate;
import java.time.Period;

/**
 * 学编程，关注：十代码农
 * 抖音、快手、B站、西瓜视频、今日头条
 */
public class DateDemo3 {
    public static void main(String args[]) {
        calculateTimeDifferenceByPeriod(2022, 2, 4);
    }

    public static void calculateTimeDifferenceByPeriod(int year, int month, int dayOfMonth) {
        LocalDate today = LocalDate.now();
        System.out.println("今天：" + today);
        LocalDate destDate = LocalDate.of(year, month, dayOfMonth);
        System.out.println("目标日期：" + destDate);

        Period p = Period.between(today, destDate);
        System.out.printf("时间差：%d 年 %d 个月 %d 天\n", p.getYears(), p.getMonths(), p.getDays());
    }
}